﻿#region Namespace imports

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

#endregion

namespace AdventureGame
{
    internal class Area
    {
        public Boolean _beenHere;
        public String _description;
        public String _downRoom = "-";
        public String _east = "-";

        public String _enter;
        public String _everyTurn;
        public String _exit;
        public List<Item> _Items = new List<Item>();
        public String _monsters;
        public String _monsters2;
        public String _moveEast;
        public String _moveNorth;
        public String _moveSouth;
        public String _moveWest;
        public String _name;
        public String _displayName;

        public String _north = "-";
        public String _postBattle;
        public String _south = "-";
        public String _upRoom = "-";

        public Boolean _victory;
        public String _west = "-";


        public Area(StreamReader stream)
        {
            String line;

            _name = stream.ReadLine().Trim();
            _north = stream.ReadLine().Trim().ToLower();
            _south = stream.ReadLine().Trim().ToLower();
            _east = stream.ReadLine().Trim().ToLower();
            _west = stream.ReadLine().Trim().ToLower();
            _description = stream.ReadLine();
            _displayName = _name;

            while (!stream.EndOfStream && ((line = stream.ReadLine().ToLower().Trim()) != ""))
            {
                if (line == "enter:")
                {
                    _enter = stream.ReadLine().Trim();
                }
                else if (line == "exit:")
                {
                    _exit = stream.ReadLine().Trim();
                }
                else if (line == "item:")
                {
                    _Items.Add(new Item(stream.ReadLine().Trim().ToLower()));
                }
                else if (line == "monster:")
                {
                    _monsters = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "monster2:")
                {
                    _monsters2 = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "movenorth:")
                {
                    _moveNorth = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "movesouth:")
                {
                    _moveSouth = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "moveeast:")
                {
                    _moveEast = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "movewest:")
                {
                    _moveWest = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "everyturn:")
                {
                    _everyTurn = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "post combat:")
                {
                    this._postBattle = stream.ReadLine().Trim().ToLower();
                }
                else if (line == "display name:")
                {
                    this._displayName = stream.ReadLine().Trim();
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("This line could not be read:");
                    Console.WriteLine(line);
                    Console.ReadLine();
                }
            }
        }


        public String movement()
        {
            while (true)
            {
                Combat._fire = false;
                Combat._icicles = false;
                Combat._mirror = false;
                Hero.ResetStats();
                if (Hero.GrabHp() <= 0)
                {
                    Console.WriteLine("You die...");
                    return "Death";
                }

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine(_displayName + "   Hp: {0}", Hero.GrabHp());
                


                if (!_beenHere)
                {
                    Console.WriteLine(_description);
                    if (enter() == "return")
                    {
                        return "NorthWest";
                    }
                    World.explored++;
                }

                if (_Items.Count() > 0)
                {
                    Console.WriteLine("Here there is:");
                    foreach (Item Item in _Items)
                    {
                        Console.WriteLine(Item.Name);
                    }
                }

                if (Hero.GrabPoison())
                {
                    Random rand = new Random();
                    Int32 random1 = rand.Next(5);
                    Hero.SetHp(random1);
                    Console.WriteLine("You take {0} poison damage!", random1);
                    Int32 random2 = rand.Next(10);
                    if (random2 >= 7)
                    {
                        Console.WriteLine("You recover from your poisoning!");
                        Hero.SetPoison(false);
                    }
                }

                if (EveryTurn() == "Death")
                {
                    return "Death";
                }


                if (_monsters != null && _monsters2 != null)
                {
                    Console.WriteLine();
                    String win = Combat.DoubleBattle(_monsters, _monsters2);
                    if (win == "win")
                    {
                        _monsters = null;
                        _monsters2 = null;
                        PostBattle();
                        _beenHere = true;
                        continue;
                    }
                    else if (win == "flee")
                    {
                        if (_victory)
                        {
                            _beenHere = true;
                            Console.WriteLine("\"Fleeing are we? You pathetic fool. There is no escape!\"");
                            continue;
                        }
                    }
                    else
                    {
                        return "Death";
                    }
                }
                else if (_monsters != null)
                {
                    Console.WriteLine();
                    String win = Combat.Battle(_monsters);
                    if (win == "win")
                    {
                        Console.WriteLine();
                        _monsters = null;
                        PostBattle();
                        if (_victory)
                        {
                            World.Victory();
                            return "Death";
                        }
                        _beenHere = true;
                        continue;
                    }
                    else if (win == "flee")
                    {
                        if (_victory)
                        {
                            Console.WriteLine("\"Fleeing are we? You pathetic fool. There is no escape!\"");
                            _beenHere = true;
                            continue;
                        }
                    }
                    else
                    {
                        return "Death";
                    }
                }


                _beenHere = true;
                String command = Console.ReadLine().Trim();
                command = command.ToLower();
                Console.WriteLine();

                if (command == "n" | command == "north")
                {
                    if (_north != "-")
                    {
                        String north = MoveNorth();

                        if (north == "Death")
                        {
                            return "Death";
                        }

                        return north;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }

                else if (command == "s" | command == "south")
                {
                    if (_south != "-")
                    {
                        String south = MoveSouth();
                        if (south == "Death")
                        {
                            return "Death";
                        }
                        return south;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }

                else if (command == "w" | command == "west")
                {
                    if (_west != "-")
                    {
                        String west = MoveWest();
                        if (west == "Death")
                        {
                            return "Death";
                        }
                        return west;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }

                else if (command == "e" | command == "east")
                {
                    if (_east != "-")
                    {
                        String east = MoveEast();
                        if (east == "Death")
                        {
                            return "Death";
                        }
                        return east;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }
                if (command == "u" | command == "up")
                {
                    if (_upRoom != "-")
                    {
                        return _upRoom;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }

                if (command == "d" | command == "down")
                {
                    if (_downRoom != "-")
                    {
                        return _downRoom;
                    }
                    else
                    {
                        Console.WriteLine("You can't go that way.");
                        continue;
                    }
                }

                else if (command == "take" | command == "t")
                {
                    if (_Items.Count() > 0)
                    {
                        Console.WriteLine("What do you want to take?");
                        String command2 = Console.ReadLine().Trim();
                        command2 = command2.ToLower();


                        for (Int32 i = 0; i <= _Items.Count() - 1; i++)
                        {
                            if (FindItem(_Items[i], command2))
                            {
                                _Items.RemoveAt(i);
                                Console.WriteLine("{0} Taken", command2);
                                Hero.AddToInventory(command2);
                                break;
                            }
                            if (i >= _Items.Count() - 1)
                            {
                                Console.WriteLine("There's no {0} here that you can take!", command2);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("There's nothing here!");
                    }

                    Console.WriteLine();
                }

                else if (command == "drop" | command == "dr")
                {
                    if (Hero._Inventory.Count() > 0 || Hero.GrabManaPot() > 0 || Hero.GrabPot() > 0)
                    {
                        Console.WriteLine("What do you want to drop?");
                        String command2 = Console.ReadLine().Trim();
                        command2 = command2.ToLower();


                        if (command2 == "potion")
                        {
                            Hero.SetPot(-1);
                            _Items.Add(new Item(command2));
                            Console.WriteLine("potion dropped");
                        }
                        else if (command2 == "mana potion")
                        {
                            Hero.SetManaPot(-1);
                            _Items.Add(new Item(command2));
                            Console.WriteLine("mana potion dropped");
                        }
                        else
                        {
                            Boolean dropsuccess = false;
                            for (Int32 i = 0; i <= Hero._Inventory.Count() - 1; i++)
                            {
                                if (FindItem(Hero._Inventory[i], command2))
                                {
                                    Hero._Inventory.RemoveAt(i);
                                    Console.WriteLine("{0} Dropped", command2);
                                    dropsuccess = true;
                                    _Items.Add(new Item(command2));
                                    break;
                                }
                                if (i >= _Items.Count() - 1)
                                {
                                    Console.WriteLine("You don't have a {0}!", command2);
                                    break;
                                }
                            }
                            if (!dropsuccess)
                            {
                                Console.WriteLine("You don't have a {0}!", command2);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("You don't have anything!");
                    }

                    Console.WriteLine();
                }

                else if (command == "status" || command == "st")
                {
                    Console.WriteLine("Your Status");
                    Console.WriteLine("Hp: {0}", Hero.GrabHp());
                    Console.WriteLine("Atk: {0}", Hero.GrabAtk());
                    Console.WriteLine("Def: {0}", Hero.GrabDef());
                    Console.WriteLine("Eva: {0}", Hero.GrabEva());
                    Console.WriteLine("Acc: {0}", Hero.GrabAcc());
                    Console.WriteLine("Mag: {0}", Hero.GrabMag());
                    Console.WriteLine("Res: {0}", Hero.GrabRes());
                    Console.WriteLine("Potions: {0}", Hero.GrabPot());
                    Console.WriteLine("Mana potions: {0}", Hero.GrabManaPot());
                    Console.WriteLine("Spells: {0}", Hero.GrabSpe());
                    Console.WriteLine("Spells Known:");

                    if (Hero.SpellBlast)
                    {
                        Console.WriteLine("\tBlast");
                    }

                    if (Hero.SpellParalyze)
                    {
                        Console.WriteLine("\tParalyze");
                    }

                    if (Hero.SpellPoison)
                    {
                        Console.WriteLine("\tPoison");
                    }

                    if (Hero.SpellHeal)
                    {
                        Console.WriteLine("\tHeal");
                    }

                    if (Hero.SpellWeaken)
                    {
                        Console.WriteLine("\tWeaken");
                    }

                    if (Hero.SpellEnhance)
                    {
                        Console.WriteLine("\tEnhance");
                    }

                    continue;
                }
                else if (command == "potion" || command == "p")
                {
                    Hero.Potion();
                }
                else if (command == "mana potion" || command == "m")
                {
                    Hero.ManaPotion();
                }
                else if (command == "inventory" | command == "i")
                {
                    Hero.inventory();
                }

                else if (command == "equip" | command == "q")
                {
                    if (Hero.Weapons())
                    {
                        Console.WriteLine("What do you equip?");
                        String command2 = Console.ReadLine().Trim();
                        command2 = command2.ToLower();

                        if (command2 == "")
                        {
                            Hero.unequip();
                        }
                        else
                        {
                            Hero.Equip(command2);
                        }
                    }
                }
                else if (command == "read" | command == "r")
                {
                    if (Hero.Scrolls())
                    {
                        Console.WriteLine("What do you read?");
                        String command2 = Console.ReadLine().Trim();
                        command2 = command2.ToLower();

                        if (command2 == "")
                        {
                            Console.WriteLine("Never mind");
                        }
                        else
                        {
                            Hero.Read(command2);
                        }
                    }
                }
                else if (command == "don" | command == "d")
                {
                    if (Hero.Armors())
                    {
                        Console.WriteLine("What do you don?");
                        String command2 = Console.ReadLine().Trim();
                        command2 = command2.ToLower();

                        if (command2 == "")
                        {
                            Hero.TakeOff();
                        }

                        Hero.Don(command2);
                    }
                }
                else if (command == "look" | command == "l")
                {
                    Console.WriteLine(_description);
                }
                else
                {
                    Console.WriteLine("Your command is incomprehensible.");
                }
            }
        }

        public static Boolean FindItem(Item apple, String what)
        {
            return apple.Name == what;
        }

        private String enter()
        {
            if (_enter == "witch")
            {
                Witch1();
            }
            else if (_enter == "witch2")
            {
                Witch2();
            }
            else if (_enter == "torch")
            {
                if (!Puzzles.PuzzleModeBegin("torch"))
                {
                    return "Death";
                }
            }
            else if (_enter == "sand")
            {
                if (!Puzzles.PuzzleModeBegin("sand"))
                {
                    return "Death";
                }
            }
            else if (_enter == "marsh")
            {
                if (!Puzzles.PuzzleModeBegin("marsh"))
                {
                    return "Death";
                }
            }
            else
            {
                Console.WriteLine(_enter);
            }


            return "";
        }

        private String EveryTurn()
        {
            if (_everyTurn == "icicle")
            {
                Icicle();
            }
            else if (_everyTurn == "fire")
            {
                Fire();
            }
            else if (_everyTurn == "trap")
            {
                Trap();
            }
            
            else
            {
                Console.WriteLine(_everyTurn);
            }

            return "";
        }

        private String PostBattle()
        {
            if (_postBattle == "witch")
            {
                Console.WriteLine("From the witch's body rises a silver key.");
                this._Items.Add(new Item("silver key"));
                Hero.Password1 = true;
            }
            else if (_postBattle == "mummy")
            {
                Console.WriteLine("From the mummy's body rises a silver key.");
                this._Items.Add(new Item("silver key"));
                Hero.Password1 = true;
            }
            else if (_postBattle == "yeti")
            {
                Console.WriteLine("As the yeti falls the dark portal shatters!");
                Console.WriteLine("You feel a weight lifted off your chest.");
                World._world2["ice cave"]._west = "glacier entrance";
                World._world2["glacier entrance"]._east = "ice cave";
                Hero.Portal = true;
            }
            else if (_postBattle == "dragon")
            {
                Console.WriteLine("As the dragon is slain the dark portal shatters!");
                Console.WriteLine("You feel a weight lifted off your chest.");
                Hero.Portal = true;
            }
            else if (_postBattle == "general")
            {
                Console.WriteLine("As you lay the terrible thing low, the other trolls flee and you hear cries of fear from amoung their ranks. A large decorated soldier comes up to you with a grim look on his face. \"I don't know who you are or where you acquired the power to take out something like that... But I thank you for your assistance. The last of the trolls have fled our camp so we are going to strike back! Come with us. We will now destroy their defense field and enter their camp to the far East.\"");
                Hero.Camp = true;
            }
            else if (_postBattle == "mormorda")
            {
                World.Mormorda1();
            }
            else if (_postBattle == "victory")
            {
                World.Victory();
            }
            else
            {
                Console.WriteLine(_postBattle);
            }

            return "";
        }

        private String MoveNorth()
        {
            if (_exit == "reset")
            {
                _beenHere = false;
            }
            else if (_exit == "mirror")
            {
               return Mirror();
            }
            else if (_moveNorth == "password")
            {
                Console.WriteLine("A silver lock appears on the gate!");
                if (Hero.Key1())
                {
                    Console.WriteLine("The silver key fits!");
                    Console.WriteLine("The gate opens into darkness...");
                    return _north;
                }
                else
                {
                    Console.WriteLine("You can't unlock the gate!");
                    return _name;
                }
            }
            else if (_moveNorth == "portal")
            {
                Console.WriteLine("you hear a booming voice call out:");
                Console.WriteLine("\"By order of the Queen Espeleth of Caldremot!\"");
                Console.WriteLine("\"This gate shall be closed for war purposes until the Dark is banished from Mount Zinath or Svalarin Glacier!\"");
                if (Hero.Portal)
                {
                    Console.WriteLine("\"Ah, you were the one who banished the Dark from these caverns!\"");
                    Console.WriteLine("\"You are worthy and may proceed, but be warned! The Caverns ahead are a war zone. Tread carefully...\"");
                    Console.WriteLine("The Gate opens!");
                    return _north;
                }
                else
                {
                    Console.WriteLine("\"Even heroes cannot pass in wartime. These Caverns must be sealed or the Dark will further corrupt the Caverns beyond. Go back.\"");
                    return _name;
                }
            }
            else if (_moveNorth == "riddle")
            {
                if (Riddle())
                {
                    return _north;
                }
                else
                {
                    return _name.ToLower();
                }
            }
            else if (_moveNorth == "zombies")
            {
                if (Hero.Zombies)
                {
                    Console.WriteLine("The gate, you realize, is blasted open! What lies inside?");
                    return _north;
                }
                else
                {
                    Console.WriteLine("\"By order of Queen Espeleth! None shall pass!\"");
                    return _name.ToLower();
                }
            }
            else if (_moveNorth == "trial")
            {
                if (Trial())
                {
                    return _north;
                }
                else
                {
                    return "death";
                }
            }
            else if (_exit == "lava")
            {
                if (Lava())
                {
                    return _north;
                }
                else
                {
                    return "death";
                }
            }
            else if (_exit == "marsh")
            {
                if (Puzzles.PuzzleModeBegin("marsh"))
                {
                    return this._north;
                }
                else
                    return "Death";
            }
            else
            {
                Console.WriteLine(_moveNorth);
            }

            return _north;
        }

        private String MoveSouth()
        {
            if (_exit == "reset")
            {
                _beenHere = false;
            }
            else if (_exit == "mirror")
            {
                return Mirror();
            }
            else if (_exit == "marsh")
            {
                if (Puzzles.PuzzleModeBegin("marsh"))
                {
                    return this._south;
                }
                else
                    return "Death";
            }
            else if (_exit == "lava")
            {
                if (Lava())
                {
                    return _south;
                }
                else
                {
                    return "death";
                }
            }
            else
            {
                Console.WriteLine(_moveSouth);
            }

            return _south;
        }

        private String MoveEast()
        {
            if (_exit == "reset")
            {
                _beenHere = false;
            }
            else if (_exit == "mirror")
            {
                return Mirror();
            }
            else if (_moveEast == "lake")
            {
                String outcome = Puzzles.Lake();
                if (outcome == "w")
                {
                    return _name.ToLower();
                }
                else if (outcome == "e")
                {
                    return _east;
                }
                else
                {
                    return "Death";
                }
            }
            else if (_moveEast == "clear")
            {
                
                if (World._world2["troll front lines"]._monsters == null && World._world2["drilling field"]._monsters == null && World._world2["troll armory"]._monsters == null && World._world2["troll barraks"]._monsters == null && World._world2["lookout tower"]._monsters == null && World._world2["fortified tower"]._monsters == null && World._world2["dark gate"]._monsters == null)
                {
                    Console.WriteLine("The commander shouts \"All right men! The camp is clear! Let us free these Caverns once and for all!\" The soldiers charge and the gait falls...");
                    return _east;
                    
                }
                else  
                {
                    Console.WriteLine("The Commander yells \"Wait! the camp isn't clear yet! There are still trolls about!\"");
                    return _name.ToLower();
                }
               
            }
            else if (_exit == "lava")
            {
                if (Lava())
                {
                    return _east;
                }
                else
                {
                    return "death";
                }
            }
            else if (_moveEast == "camp")
            {
                if (Hero.Camp)
                {
                    Console.WriteLine("A massive wave of human soldiers comes from the West and demolishes the barrier with blasts of magic. They pour inside as do you.");

                    return _east;
                }
                else
                {
                    Console.WriteLine("The barrier is impenitrable.");
                    return _name;
                }
            }
            else if (_moveEast == "waterfall")
            {
                String outcome = Puzzles.Waterfall();
                if (outcome == "w")
                {
                    return _name.ToLower();
                }
                else if (outcome == "e")
                {
                    return _east;
                }
                else
                {
                    return "Death";
                }
            }
            else if (_exit == "marsh")
            {
                if (Puzzles.PuzzleModeBegin("marsh"))
                {
                    return this._east;
                }
                else
                    return "Death";
            }
            else
            {
                Console.WriteLine(_moveEast);
            }

            return _east;
        }

        private String MoveWest()
        {
            if (_exit == "reset")
            {
                _beenHere = false;
            }
            else if (_exit == "mirror")
            {
                return Mirror();
            }
            else if (_moveWest == "lake")
            {
                String outcome = Puzzles.Lake();
                if (outcome == "e")
                {
                    return _name.ToLower();
                }
                else if (outcome == "w")
                {
                    return _west;
                }
                
                else
                {
                    return "Death";
                }
            }
            else if (_exit == "lava")
            {
                if (Lava())
                {
                    return _west;
                }
                else
                {
                    return "death";
                }
            }
            else if (_moveWest == "waterfall")
            {
                Console.WriteLine("You slip and slide easily down the waterfall.");
                return _west;
            }
            else if (_exit == "marsh")
            {
                if (Puzzles.PuzzleModeBegin("marsh"))
                {
                    return this._west;
                }
                else
                    return "Death";
            }
            else
            {
                Console.WriteLine(_moveWest);
            }

            return _west;
        }

        private static void Icicle()
        {
            Console.WriteLine();
            Combat._icicles = true;
            Random rrr = new Random();

            if (rrr.Next(10) >= 5)
            {
                Console.WriteLine("An icicle falls from the celing!");

                if (rrr.Next(100) - Hero.GrabEva() >= 50)
                {
                    Console.WriteLine("You are hit by the icicle!");
                    Int32 damage = rrr.Next(20) - Hero.GrabDef();
                    if (damage <= 0)
                    {
                        damage = 1;
                    }
                    Hero.SetHp(damage);
                    Console.WriteLine("You take {0} damage", damage);
                }
                else
                {
                    Console.WriteLine("You leap aside and nimbly dodge it!");
                }
            }
            Console.WriteLine();
        }


        public static void Fire()
        {
            Combat._fire = true;

            Random rand = new Random();
            Int32 damage = rand.Next(10);
            Hero.SetHp(damage);

            Console.WriteLine("You are burned!");
            Console.WriteLine("You take {0} damage!", damage);
            Console.WriteLine();
        }

        private string Mirror()
        {
            Combat._mirror = true;
            Console.WriteLine("The mirrors bewilder you");
            Random rand = new Random();

            Int32 chance = rand.Next(11);

            if (chance > 9)
            {
                Console.WriteLine("You feel sick.");
                Hero.SetPoison(true);
            }
            else if (chance > 8)
            {
                Console.WriteLine("You wander aimlessly...");
                return _name;
            }
            else if (chance > 6)
            {
                Combat._mirror = true;
                Combat.Battle("zombie");
                Console.WriteLine("Wait a second... You were fighting your reflection!");
            }
            else if (chance > 5)
            {
                Console.WriteLine("You trip and hurt yourself");
                Int32 damage = rand.Next(15);
                Hero.SetHp(damage);
                Console.WriteLine("You take {0} damage!", damage);
            }
            else if (chance > 4)
            {
                Console.WriteLine("You wander aimlessly...");
                return _west;
            }
            else if (chance > 3)
            {
                Console.WriteLine("You wander aimlessly...");
                return _east;
            }
            else if (chance > 2)
            {
                Console.WriteLine("You wander aimlessly...");
                return _south;
            }
            else if (chance > 1)
            {
                Console.WriteLine("You wander aimlessly...");
                return _north;
            }
            else
            {
                return _name;
            }
            Console.WriteLine();
            return _name;
        }

        private void Trap()
        {
            Console.WriteLine("You trigger a trap!");
            Random rand = new Random();

            Int32 chance = rand.Next(11);

            if (chance > 8)
            {
                Console.WriteLine("The blade of an axe swings at you!");


                Random rando = new Random();
                Int32 random1 = rando.Next(100);
                Int32 hit = 100 - Hero.GrabEva();
                Boolean bHit = false;
                if (hit < 1)
                {
                    hit = 1;
                }
                if (random1 <= hit)
                {
                    bHit = true;
                }
                else
                {
                    bHit = false;
                }
                if (bHit)
                {
                    Console.WriteLine("The axe hits!");
                }
                else
                {
                    Console.WriteLine("The axe misses.");
                }

                if (bHit)
                {
                    Random rande = new Random();
                    Int32 rand1 = rande.Next(15);
                    Int32 rand2 = rande.Next(Hero.GrabDef());
                    Int32 damage = rand1 - rand2;
                    if (damage < 1)
                    {
                        damage = 1;
                    }
                    Console.WriteLine("The axe deals {0} damage!", damage);
                }
            }
            if (chance > 5)
            {
                Console.WriteLine("A magical blast engulfes you!");


                Random randf = new Random();
                Int32 random1 = randf.Next(100);
                Int32 hit = 50 + 10 - Hero.GrabRes();

                if (random1 <= hit)
                {
                    Console.WriteLine("The magic paralyses you!");
                    Hero.SetParalyze(true);
                }
                else
                {
                    Console.WriteLine("The {0}'s magic fails!");
                }

                Console.WriteLine("An alarm goes off!");

                _monsters = "troll myrmidon";
            }
            else
            {
                Console.WriteLine("A poisoned arrow flies at you!");

                Console.WriteLine("The arrow hits you!");

                Random randd = new Random();
                Int32 random1 = randd.Next(100);
                Int32 hit = 50 + 10 - Hero.GrabRes();

                if (random1 <= hit)
                {
                    Console.WriteLine("It poisons you!!");

                    Hero.SetPoison(true);
                }
                else
                {
                    Console.WriteLine("You shrug off the poison!");
                }
            }
        }

        private Boolean Riddle()
        {
            Console.WriteLine("You hear a booming voice call out to you:");
            Console.WriteLine("What can only be seen when you cannot see and creeps into every home?");

            Console.WriteLine("What is your answer?");
            String command = Console.ReadLine().Trim();
            command = command.ToLower();

            if (command == "the dark" | command == "darkness")
            {
                Console.WriteLine("Thou art wise");
                Console.WriteLine("The Gate opens!");
                return true;
            }
            else
            {
                Console.WriteLine("You Fool!");
                Console.WriteLine("Feel your punishment!");
                _monsters = "ogre";
                return false;
            }
        }

        private Boolean Trial()
        {
            Console.WriteLine();
            Console.WriteLine("You hear a voice call out to you. Its voice crackles like flames.");
            Console.WriteLine("\"Ha ha ha! one still lives! Truly amazing! You want to get to the peak? Well, you'll have to pass my trial first! If you pass, the new Lord of the Mountain can eat you alive. If not... Well, he'll get to eat you cooked!\"");
            Console.WriteLine("\"In this Trial, you have a choice! Isn't that lovely? Endure terrible pain, fight a demon of fire, or tell a good joke.\"");
            Combat._fire = true;

            for (int i = 3; i >= 0; i-- )
            {
                Console.WriteLine();
                if (Hero.GrabHp() <= 0)
                {
                    Console.WriteLine("\"Ha ha! You're dead!\"");
                    return false;
                }
                if (i != 3)
                    Console.WriteLine("Good job! Only {0} more trials left!", i);

                Console.WriteLine("Which do you choose: pain, fight, or joke? (p/f/j)");
                string command = Console.ReadLine().Trim();
                command = command.ToLower();

                if (command == "p" || command == "pain")
                {
                    Fire();
                    Fire();
                }
                else if (command == "f" || command == "fight")
                {
                    Combat.Battle("fire elemental");
                }
                else if (command == "j" || command == "joke")
                {
                    Console.WriteLine("\"Hee hee, what is it?\"");
                    Console.ReadLine();

                    Random rand = new Random();
                    int chance = rand.Next(10);

                    if (chance >= 5)
                    {
                        Console.WriteLine("\"That is the lamest joke I have ever heard.\"");
                        Console.WriteLine("\"Just for that, you must complete three more trials! Hee hee.\"");
                        i = 4;
                    }
                    else
                    {
                        Console.WriteLine("\"Ha ha ha! Hee hee hee! Ho ho ho! Hi hi hi! Hu hu hu! Hy hy hy!\"");
                    }
                }
                else
                {
                    Console.WriteLine("That's no fun.");
                    i++;
                    
                }

            }
            
            Console.WriteLine("\"That was fun! It'll be even funner to see master incinerate you!\"");
            Int32 xp = 80;
            Console.WriteLine("You gained {0} Xp!", xp);
            Hero.SetXp(xp);
            if (Hero.GrabXp() >= Hero.GrabToNextLevel())
            {
                Hero.LevelUp();
            }
            
            return true;
        }

        private Boolean Lava()
        {
            
            for (int i = 0; i <= 7; i++)
            {
                if (i < 0)
                {
                    i = 0;
                }
                if (Hero.GrabHp() <= 0)
                {
                    Console.WriteLine("You die...");
                    return false;
                }

                
                Console.WriteLine("You are {0}/7 of the way there!", i);

                Console.WriteLine("Do you hop quicky or slowly? (Q/S)");

                Random rando = new Random();
                int chance = rando.Next(10);

                string command = Console.ReadLine().Trim();
                command = command.ToLower();

                Console.WriteLine();
                if (command == "q")
                {
                    Console.WriteLine("You deftly hop from rock to rock.");
                    i++;
                    chance++;
                }
                else
                {
                    Console.WriteLine("You make your way carefully across the rocks.");
                }

                if (chance >= 8)
                {
                    Console.WriteLine();
                    Console.WriteLine("You feel you are going to fall!");
                    Console.WriteLine("Do you jump forward of step back onto a more stable rock? (F/B)");

                    command = Console.ReadLine().Trim();
                    command = command.ToLower();

                    if (command == "f")
                    {
                        Fire();
                    }
                    else
                    {
                        i--;
                        i--;
                    }
                }
                else if (chance >= 5)
                {
                    Fire();
                }

            }
            Console.WriteLine("You make it across the Lava!");
            Int32 xp = 80;
            Console.WriteLine("You gained {0} Xp!", xp);
            Hero.SetXp(xp);
            if (Hero.GrabXp() >= Hero.GrabToNextLevel())
            {
                Hero.LevelUp();
            }

            return true;
        }


        private void Witch1()
        {
            Console.WriteLine("As you step inside a kindly old woman gets up from her pot of stew and smiles.");
            Console.WriteLine(
                "\"It's been a long time since I've had visiters. Come, come have a seat by the fire and have some soup.\"");
            Console.WriteLine("The soup looks tasty... Do you try it? (Y/N)");

            String command1 = Console.ReadLine().Trim();
            command1 = command1.ToLower();

            if (command1 == "y")
            {
                Console.WriteLine();
                Console.WriteLine(
                    "The soup tastes wonderful as you sip it, but as soon as you swallow it becomes foul. It feels like spiders and worms are sliding down your throat!");
                Hero.SetParalyze(true);
                Hero.SetPoison(true);

                Console.WriteLine("You are poisoned!");
                Console.WriteLine("You are paralyzed!");
                Console.WriteLine();
                Console.WriteLine("The woman steps over to you smiling menacingly");
                Console.WriteLine("\"Looks like you'll go nicely in that soup...\"");
                _beenHere = true;
                _enter = null;
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("The woman's nostrals flare and her kindliness is gone. She steps forward menacingly.");
                Console.WriteLine("\"Well, if you don't like the soup, I suppose you'll just have to in it!!!\"");
                _beenHere = true;
                _enter = null;
            }
        }


        private void Witch2()
        {
            Console.WriteLine(
                "You look around to see a young girl tending the soup pot. She ghasps as you enter and, realizes you aren't a troll rushes to you.");
            Console.WriteLine(
                "\"Oh, thank god you've come! I've been held here three days! Before you storm the Tower, please have some soup.\"");
            Console.WriteLine("The soup looks tasty... Do you try it? (Y/N)");

            String command1 = Console.ReadLine().Trim();
            command1 = command1.ToLower();

            if (command1 == "y")
            {
                Console.WriteLine();
                Console.WriteLine(
                    "The soup tastes delicious as you sip it, but as soon as you swallow it becomes foul. It feels like spiders and worms are sliding down your throat!");
                Hero.SetParalyze(true);
                Hero.SetPoison(true);

                Console.WriteLine("You are poisoned!");
                Console.WriteLine("You are paralyzed!");
                Console.WriteLine();
                Console.WriteLine("The girl advances on you with an evil smile.");
                Console.WriteLine("\"Looks like you'll go nicely in that soup...\"");
                _beenHere = true;
                _enter = null;
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("The girl shrieks in anger and her innocence is gone. She steps forward menacingly.");
                Console.WriteLine("\"Well, if you don't like the soup, I suppose you'll just have to go in it!!!\"");
                _beenHere = true;
                _enter = null;
            }
        }
    }
}
